home *** CD-ROM | disk | FTP | other *** search
- %
- #EF
- #T15,1,Chapter 4 Animation Pg. 4
- #HS,1,4,80,25,11,1
- #C4,R5
- ~Y~I
- ~W~IBit Block Animation~Y~I
-
- The most common form of animation used on PCs is bit block transfer (btblt),
- also called pixel block transfer (pixblt).
-
- #WN
- Btblts are done by ~C~Igrabbing a portion of the underlying screen image, saving
- it in memory, drawing something at that location, restoring the underlying
- image,~Y~I and repeating the process in a slightly different position.
- Figure 4.1 shows the btblt process.
-
- #WN
- %
- #EF
- #T15,1,Chapter 4 Animation Pg. 5
- #HS,1,4,80,25,11,1
- #C1,R3
- ~Y~I
- ~W~IFigure 4.1~Y~I
- The Bit Block Transfer Process
-
- Background Screen Image Pixel Image
-
- │ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
- ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐ ┌────┐ ┌────┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘ └────┘ └────┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘ │ │
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐ └───────┘
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ │
-
-
- #D3
- #C40,R16
- ~W~ISave The Underlying Image To RAM~Y~I
- #D1
- #ES,15,12,31,17
- #C45,R18
- ─┼─┼─┼─┼─┼─┼─┼─┼─
- ─┼─┼─┼─┼─┼─┼─┼─┼─
- ─┼─┼─┼─┼─┼─┼─┼─┼─
- ─┼─┼─┼─┼─┼─┼─┼─┼─
- ─┼─┼─┼─┼─┼─┼─┼─┼─
- #D4
- #C23,R24
- ~W~ICopy The Pixel Image To The Screen~Y~I
- #D1
- #C17,R13
- ┌────┐ ┌────┐
- └────┘ └────┘
-
- │ │
- └───────┘
- #D3
- #EL,24
- #C23,R24
- ~W~ILeave It There For A While~Y~I
- #D4
- #EL,24
- #C18,R24
- ~W~IThen Restore The Underlying Image To The Screen~Y~I
- #D1
- #ES,15,12,31,17
- #ES,45,17,61,22
- #C1,R9
- │ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐ ┌─┐
- ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ┌───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └───┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┐
- ────┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼─┼───┘
- └─┘ └─┘ └─┘ └─┘ └─┘ └─┘ │
- #EL,24
- #C18,R23
- ~W~IThen Restore The Underlying Image To The Screen~Y~I
- #WP
- %
- #EF
- #T15,1,Chapter 4 Animation Pg. 6
- #HS,1,4,80,25,11,1
- #C4,R5
- ~Y~I
- If we want to make a ball bounce across the screen, we can use the |BGI|
- ~C~Igetimage()~Y~I function to save what is currently at the spot where the
- ball will be drawn. We then transfer a block of pixels to the screen that
- form a picture of a ball. In our software we will use the BGI function
- ~C~Iputimage()~Y~I to do this. After the user has seen this image, we erase it
- by restoring whatever was there before, and we start the process all over
- again in another spot.
-
- #WN
- #C4,R14
- What if we want to animate a stationary image? If for instance, we have a
- character in our game, we may want to show him talking. To accomplish this
- illusion, we paint his face on the screen with his mouth closed, save the
- area around his mouth with ~C~Igetimage()~Y~I, use ~C~Iputimage()~Y~I to put up a picture
- of his mouth open, then restore the image of the mouth in a closed position.
- If done reasonably fast, the face will look like he's talking.
-
- #WP
- %
- #EF
- #T15,1,Chapter 4 Animation Pg. 7
- #HS,1,4,80,25,11,1
- #C4,R5
- ~Y~I There is a problem with this method though. In our ball example, we
- assumed that the background was uniform and that the background in the
- square that encloses the ball is the same color as the background of the
- screen. This enabled us to copy the ball directly into video RAM.
-
- #WN
- If the background is non-uniform, or if the background in the
- |square around the ball| is a different color than the background color,
- the image won't look right. We must find a way of combining the image of
- the ball with the background image without changing anything but the
- actual image of the ball.
-
- #WN
- #C4,R16
- One of the ways that this can be done is by using a cutout shown in
- Figure 4.2. The illustration shows a ball. The background in the smallest
- enclosing rectangle is set to the color whose numeric value is |zero|. If
- we combine the cutout with the screen image by bitwise or'ing the pixels,
- the area overlapped by the cutout background will remain as it is.
-
- #WP
- %
- #EF
- #T15,1,Chapter 4 Animation Pg. 8
- #HS,1,4,80,25,11,1
- #C4,R5
- ~Y~I
- The place in the cutout where the actual ball will go is colored white. On
- the PC, a white pixel has a binary value of all 1's. If we use a bitwise
- or, the white area in the cutout will force the spot on the screen where
- the ball will be drawn to turn white, as in Figure 4.2.
-
- #WN
- Finally, we combine a negative image of the ball with the actual image on
- the spot where we have placed the cutout, as shown in Figure 4.2. We do
- this using a bitwise exclusive or. This preserves the area where the black
- enclosing rectangle of the image overlaps onto the screen image. What we
- wind up with is the image of a ball seamlessly integrated onto the screen
- image. This technique can be used to animate any figure around the screen.
-
-
- #WP
- #Uarc4_2.exe
- #QT,T,arc4_3
- #X